#include<bits/stdc++.h>
using namespace std;
int n,m,l,v,f[100005],ans=0,t,sum=0;
struct car{
    int d,v,a;
    double cs;
}a[100005];
void work(){
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++){
        cin>>a[i].d>>a[i].v>>a[i].a;
        if(a[i].a==0){
            if(a[i].v>v) a[i].cs=a[i].d-1;
            else a[i].cs=l+1;
        }
        else{
            a[i].cs=a[i].d+(v*v-a[i].v*a[i].v)/(2*a[i].a)+0.0000001;
        }
    }
    for(int i=1;i<=m;i++){
        cin>>f[i];
        sum=max(sum,f[i]);
    }
    sort(f+1,f+m+1);
    for(int i=1;i<=n;i++){
        if(a[i].cs<f[m]) ans++;
    }
    if(ans==0) m++;
    cout<<ans<<" "<<m-1<<"\n";
    ans=0;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--) work();
    return 0;
}
